package com.rural.bus.driver.model;

import java.io.Serializable;

import org.json.JSONException;
import org.json.JSONObject;

public class Order implements Serializable {
	
//	"createTime":1449628777000,
//	"endLatitude":40.047862,
//	"remarks":null,
//	"finalPrice":null,
//	"carType":0,
//	"endLongtitude":116.363094,
//	"distance":10000,
//	"endLocation":"北领地c区",
//	"userId":4,
//	"driverId":1,
//	"userName":"马杰",
//	"userPhone":"13112345678",
//	"startLongtitude":116.324178,
//	"driverName":"陈馨(宝马湘A**897)",
//	"orderId":126,
//	"startLatitude":40.089919,
//	"orderType":1,
//	"number":1,
//	"driverPhone":"13333333331",
//	"perDistance":1.5,
//	"takeTime":9480000,
//	"startLocation":"专家国际公馆",
//	"orderStatus":1,
//	"payId":null,
//	"groupId":8881611,
//	"payStatus":null,
//	"estimatePrice":15000
	
	//expireTime
	
	/***
	 *新订单
	 */
	public static final int ORDERSTATUS_NEW=0;
	/***
	 * 已接单
	 */
	public static final int ORDERSTATUS_RECEIVED=1;
	/***
	 * 已就绪
	 */
	public static final int ORDERSTATUS_READYED=2;

	/***
	 * 已出发
	 */
	public static final int ORDERSTATUS_DEPARTED=3;
	/***
	 * 已到达
	 */
	public static final int ORDERSTATUS_REACHED=5;
	/***
	 *已完成
	 */
	public static final int ORDERSTATUS_COMPLETEED=6;
	/***
	 * 已取消
	 */
	public static final int ORDERSTATUS_CANCELED=4;

	public int orderId;

	public int driverId;

	public int userId;

	public int orderType;

	public String driverName;

	public String userName;

	public double startLongtitude;

	public double startLatitude;

	public String startLocation;

	public long takeTime;

	public String payId;

	public int payStatus;

	public double perDistance;

	public double distance;

	public int groupId;

	public String userPhone;

	public String driverPhone;

	public double finalPrice;

	public double estimatePrice;

	public int orderStatus;

	public int number;

	public int carType;

	public double endLatitude;

	public double endLongtitude;

	public String endLocation;

	public String remarks;

	public long createTime;
	
	public int expireTime = 300;  //有效时间--倒计时

	public static Order parse(JSONObject object) {
		Order order = new Order();
		try {
			order.orderId = object.getInt("orderId");
			order.startLocation = object.getString("startLocation");
			order.userId = object.getInt("userId");
			order.userName = object.getString("userName");
			order.takeTime = object.getLong("takeTime");
			order.endLocation = object.getString("endLocation");
			order.orderType = object.getInt("orderType");
			order.number = object.getInt("number");
			order.carType = object.getInt("carType");
			order.orderStatus=object.getInt("orderStatus");
			order.groupId=object.optInt("groupId", 0);
			order.driverId=object.getInt("driverId");
			order.remarks = object.optString("remarks", "");
			order.estimatePrice = object.optDouble("estimatePrice", 0);
			
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return order;
	}
	
}
